package com.work.demo.enumdemo;

/**
 * log action
 *
 * @author chaoxi
 * @since 3.0.0 2022/9/21
 **/
public enum LogActionEnum {
    // action
    CREATE("新增"),
    DELETE("删除"),
    EDIT("编辑"),
    ENABLE("启用"),
    DISABLE("禁用"),
    LOGIN("登录"),
    LOGOUT("注销"),
    RECOVER("恢复"),
    INVITE("邀请"),
    START_NETWORK("发起组网"),
    SIGN("签约"),
    NETWORK("组网"),
    RESCIND("解约"),
    CANCEL_NETWORK("取消组网"),
    APPLY("申请"),
    DOWNLOAD("下载"),
    ESCALATION("上报"),
    RUN("运行"),
    SUBMIT("提交审核"),
    APPROVE("审批"),
    QUERY("查询"),
    INIT("初始化"),
    ONLINE("上下线"),
    RESET("重置密钥"),
    RELEASE("发布或取消发布"),
    PREDICT("测试"),
    REMOVE("移除"),
    IMPORT("导入"),
    REFRESH("刷新"),
    SAVE("保存"),
    SAVE_AS("另存为"),
    SUSPEND("暂停"),
    ADD_WARE("添加组件"),
    TEST_CONNECT("测试连通性"),
    ;

    private final String desc;

    LogActionEnum(String desc) {
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    public static LogActionEnum of(String value) {
        for (LogActionEnum logAction : LogActionEnum.values()) {
            if (logAction.name().equals(value)) {
                return logAction;
            }
        }
        return null;
    }

    public static boolean exist(String value) {
        for (LogActionEnum logAction : LogActionEnum.values()) {
            if (logAction.name().equals(value)) {
                return true;
            }
        }
        return false;
    }

    public static boolean existDesc(String desc) {
        for (LogActionEnum logAction : LogActionEnum.values()) {
            if (logAction.getDesc().equals(desc)) {
                return true;
            }
        }
        return false;
    }

    public static LogActionEnum descOf(String desc) {
        for (LogActionEnum logAction : LogActionEnum.values()) {
            if (logAction.getDesc().equals(desc)) {
                return logAction;
            }
        }
        return null;
    }
}
